<?php

class Core_Backend_Component_Road_View_Info_Index extends Core_Backend_Share_View_Grid {

    public function  __construct() {
        parent::__construct();
    }

    protected function buildNavigation($navigation) {
        $navigation->addLabel($this->__('road.title.info_index'));
        parent::buildNavigation($navigation);
    }

    public function buildGrid($grid) {
    	$filter = new Kd_Object($this->getRequest()->getParameter('filter'));
        $grid->setId('info_grid')
                ->setPrimaryKey('id')
                ->setAllowFilter(TRUE)
                ->setSortField($this->getRequest()->getQuery('sort', 'id'))
                ->setSortDirection($this->getRequest()->getQuery('dir', 'asc'))
                ->setSortUrlFormat($this->getSortUrl());
        $grid->addLabelColumn($this->__('foundation.label.province'),'province_name','{province_name}')
        		->setTextboxFilter(NULL, NULL, $filter->getData('province_name'))
                ->setSortField('province_name')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('foundation.label.city'),'city_name','{city_name}')
        		->setTextboxFilter(NULL, NULL, $filter->getData('city_name'))
                ->setSortField('city_name')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('foundation.label.district'),'district_name','{district_name}')
        		->setTextboxFilter(NULL, NULL, $filter->getData('district_name'))
                ->setSortField('district_name')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('foundation.label.townstreet'),'townstreet_name','{townstreet_name}')
        		->setTextboxFilter(NULL, NULL, $filter->getData('townstreet_name'))
                ->setSortField('district_name')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('foundation.label.road'),'road_name','{road_name}')
        		->setTextboxFilter(NULL, NULL, $filter->getData('road_name'))
                ->setSortField('road_name')
                ->setWidth(100);
        $grid->addLabelColumn($this->__('share.label.status'), 'status', '{status}')
                ->setSelectFilter(NULL, NULL, Kd_Localize_Helper::getLanguageItems('status.publication'), NULL, NULL, $filter->getData('status'))
                ->setSortField('status')
                ->setAlign('center');
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('code' => '{road_id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $pagination->setUrlFormat($this->getPaginationUrl())->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }
}

